using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.Design;
using System.Security.Policy;
using System.Text;
using System.Windows.Media;
using System.Xml.Linq;

namespace RRX.Xml.ProjectTree
{
    public class ItemProjectTreeLoopPumpe : INotifyPropertyChanged, IItemProjectTree, IItemProjectTreeLoop
    {

        public ItemProjectTreeLoopPumpe() {}


        // ---------- Properties ----------
        private string name { get; set; } = "LoopPumpe230";
        public string Name
        {
            get => name;
            set
            {
                name = value;
                OnPropertyChanged("Name");
            }
        }


        private double offset { get; set; } = 200;
        public double Offset
        {
            get => offset;
            set
            {
                offset = value;
                OnPropertyChanged("Offset");
            }
        }




        // ---------- Basic ----------
        private ObservableCollection<IItemProjectTree> children { get; set; } = new ObservableCollection<IItemProjectTree>();
        public ObservableCollection<IItemProjectTree> Children
        {
            get => children;
            set
            {
                children = value;
                OnPropertyChanged("Children");
            }
        }



        // ---------- Functions ----------
        public IItemProjectTree Copy()
        {
            ItemProjectTreeLoopPumpe copy = new ItemProjectTreeLoopPumpe();

            copy.name = name;

            return copy;
        }

        public XElement Xml()
        {
            XElement xml = new XElement("pumpe");

            XElement template = XElement.Load("ProjectTree\\Templates\\TemplateLoopPumpe.xml");

            foreach (var element in template.Elements())
            {
                xml.Add(new XElement(element));
            }

            return xml;
        }


        // ---------- PropertyChanged ----------
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
        }
    }
}
